package com.ripplezjw.blog.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;

@Controller
public class LogoutController {
    @GetMapping("/logout")
    public String logout(HttpServletRequest request, @RequestParam("cur_page") String curPage) {
        request.getSession().setAttribute("user_info", null);
        System.out.println(curPage);
        if (curPage != null) return "redirect:/" + curPage;
        return "redirect:/index";
    }
}
